package homework.Day0323;

/**
 * // 构造方法，接收一个字符串
 * public StringIterator(String str);
 *
 * // 返回一个字符串中的字符
 * public String next();
 *
 * // 是否包含还未遍历到的字符
 * public boolean hasNext();
 */
public class StringIteration {
    private final String[] sarr;
    private int pos;

    public StringIteration(String[] sarr) {
        this.sarr = sarr;
    }

    public boolean hasNest(){
        return pos < sarr.length;
    }

    public String nest(){
        return sarr[pos++];
    }

    public static void main(String[] args) {
        String[] sarr = {"a","b","c","d","e","f"};
        StringIteration is = new StringIteration(sarr);
        while (is.hasNest()){
            System.out.println(is.nest());
        }
    }
}
